import React, {useRef} from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import { getRecordList} from '../service';
import moment from 'moment';
import {connect} from 'umi';
import {overtimeType,overtimeStatusType} from "@/utils/constant";

const TableList = () => {
  const actionRef = useRef();

  const columns = [
    {
      title: '申请时间',
      dataIndex: 'createTime',
      render: (text) => {
        return text !== '-' ? moment(text).format('YYYY-MM-DD') : ''
      },
    },
    {
      title: '申请人',
      dataIndex: 'oprationName',
    },
    {
      title: '申请人工号',
      dataIndex: 'oprationId',
    },
    {
      title: '加班人员',
      dataIndex: 'employeeName',
    },
    {
      title: '加班类型',
      dataIndex: 'overworkType',
      hideInSearch: true,
      render: (text) => {
        return overtimeType.find((item) => item.value === text)?.label;
      },
    },
    {
      title: '开始加班时间',
      dataIndex: 'overworkBeginTime',
      render: (text) => {
        return text !== '-' ? moment(text).format('YYYY-MM-DD HH:mm') : ''
      },
    },
    {
      title: '结束加班时间',
      dataIndex: 'overworkEndTime',
      render: (text) => {
        return text !== '-' ? moment(text).format('YYYY-MM-DD HH:mm') : ''
      },
    },
    {
      title: '开始打卡时间',
      dataIndex: 'checkBeginTime',
      render: (text) => {
        return text !== '-' ? moment(text).format('YYYY-MM-DD HH:mm') : ''
      },
    },
    {
      title: '结束打卡时间',
      dataIndex: 'checkEndTime',
      render: (text) => {
        return text !== '-' ? moment(text).format('YYYY-MM-DD HH:mm') : ''
      },
    },
    {
      title: '加班说明',
      dataIndex: 'overworkRemark',
      ellipsis:true,
      width: 200
    },
    {
      title: '状态',
      dataIndex: 'status',
      render: (text) => {
        return overtimeStatusType.find((item) => item.value === text)?.label;
      },
    },
  ];

  return (
    <PageHeaderWrapper>
      <ProTable
        actionRef={actionRef}
        search={false}
        rowKey="id"
        request={(params) => getRecordList(params)}
        columns={columns}
      />
    </PageHeaderWrapper>
  )
};
export default connect(({}) => ({}))(TableList)
